/**
 * class  VScrollThumb
 * 纵向滚动条的拖动条组件
 * author haicent
 * email haicent@126.com
 * version 0.01
 */
package as3.component.support
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import as3.component.core.free_internal;
	
	public class ScrollThumb extends BaseButton
	{
		
		private var _thumbIcon:DisplayObject;
		
		public static const MIN_HEIGHT:Number = 12;
		
		public function ScrollThumb()
		{
			super();
		}
		
		override protected function initUI():void
		{
			super.initUI();
			_uiLibrary["upImage"] = "ScrollThumb_upSkin";
			_uiLibrary["overImage"] = "ScrollThumb_overSkin";
			_uiLibrary["downImage"] = "ScrollThumb_overSkin";
			_uiLibrary["thumbIcon"] = "ScrollBar_thumbIcon";
		}
		
		override protected function creatUI():void
		{
			super.creatUI();
			
			if (_thumbIcon)
			{
				_thumbIcon.x = (_simpleButton.width - _thumbIcon.width) * 0.5;
				_thumbIcon.y = (_simpleButton.height - _thumbIcon.height) * 0.5;
				var iconBox:Sprite = new Sprite();
				iconBox.addChild(_thumbIcon);
				iconBox.mouseChildren = false;
				iconBox.mouseEnabled = false;
				addChild(iconBox);
			}
		}

		/**
		 *设置中间图标 
		 * @param dis
		 * 
		 */	
		public function set thumbIcon(dis:DisplayObject):void
		{
			if (dis && _thumbIcon != dis)
			{
				_thumbIcon = dis;
			}
		}
		
		override public function set height(value:Number):void
		{
			if (this.rotation == 0)
			{
				var _value:Number = value < MIN_HEIGHT ? MIN_HEIGHT : value;
				super.height = _value;
				if (_thumbIcon){
					_thumbIcon.x = (_simpleButton.width - _thumbIcon.width) * 0.5;
					_thumbIcon.y = (_simpleButton.height - _thumbIcon.height) * 0.5;	
				}
			}
		}
		
	}
}